<?php

	function password($length = false)
	{
		if ($length < 4) $length = rand(7, 13);
	
    $chars = "abcdefghijkmnopqrstuvwxyz023456789_";
		
    srand((double)microtime()*1000000);
    
		$i = 0;
    $pass = '' ;
    
    while ($i <= $length) {
    $num = rand() % 33;
        $tmp = substr($chars, $num, 1);
        $pass = $pass . $tmp;
        $i++;
    }
    
    return $pass;
	}
	
	
	
	function path_info() {
		$uri = $_SERVER['REQUEST_URI'];
		if (strstr($uri, '?')) $uri = substr($uri, 0, strpos($uri, '?'));
		
		return trim($uri, '/');
	}
	
	

	function phpdriver_uri($module = 'pages', $file = 'index', $query_string = false)
  {    
    if (is_array($query_string)) {
    	$q = '';
      foreach ($query_string as $k => $v) $q.= "$k=$v&";
    }
    
    $uri = '/';
    $uri.= (MOD_REWRITE === TRUE) ? "$module/$file?" : "?module=$module&amp;file=$file&amp;";
    $uri.= trim(uri_ampersands($query_string), '?');
    
    return $uri;
  }
	
	
	
	function pre($str = '')
	{
		return "<pre>$str</pre>";
	}
	
	
	
	function printr($array)
	{
		echo pre(print_r($array, true));
	}